\section{Fortran}

A formal Fortran ABI does not exist.  Most Fortran compilers are
designed for very specific high performance computing applications, so
Fortran compilers use different passing conventions and memory layouts
optimized for their specific purpose.  For example, Fortran
applications that must run on distributed memory machines need a
different data representation for array descriptors (also known as
dope vectors, or fat pointers) than applications running on symmetric
multiprocessor shared memory machines.  A normative ABI for Fortran is
therefore not desirable.  However, for interoperability of different
Fortran compilers, as well as for interoperability with other
languages, this section provides some some guidelines for data types
representation, and argument passing.  The guidelines in this section
are derived from the GNU Fortran 77 (G77) compiler, and are also
followed by the GNU Fortran 95 (\code{gfortran}) compiler (restricted to
Fortran 77 features).  Other Fortran
compilers already available for AMD64 at the time of this writing may
use different conventions, so compatibility is not guaranteed.

When this text uses the term {\em Fortran procedure}, the text applies
to both Fortran \code{FUNCTION} and \code{SUBROUTINE} subprograms as
well as for alternate \code{ENTRY} points,
unless specifically stated otherwise.

Everything not explicitly defined in this ABI is left to the implementation.

\subsection{Names}
\label{sub_fortran_names}

External names in Fortran are names of entities visible to all
subprograms at link time.  This includes names of \code{COMMON} blocks
and Fortran procedures.
To avoid name space conflicts with linked-in libraries, all external
names have to be mangled.  And to avoid name space conflicts
of mangled external names with local names, all local names must also
be mangled.
The mangling scheme is straightforward as follows:
\begin{itemize}
\item all names that do not have any underscores in it should have
{\em one} underscore appended
\item all external names containing one or
   more underscores in it (wherever) should have {\em two} underscores
   appended \footnote{Historically, this is to be compatible with f2c.}.
\item all external names should be mapped to lower case,
   following the traditional UNIX model for Fortran compilers
\end{itemize}

For examples see figure~\ref{fortran-external-names}:

\begin{figure}[H]
\Hrule
\caption{Example mapping of names} \label{fortran-external-names}
\begin{center}
\begin{footnotesize}
\begin{tabular}{l|l}
\multicolumn{1}{c}{Fortran external name}&\multicolumn{1}{c}{Linker name}\\
\hline
\code{FOO}    & \code{foo_} \\
\code{foo}    & \code{foo_} \\
\code{Foo}    & \code{foo_} \\
\code{foo_}   & \code{foo___} \\
\code{f_oo}   & \code{f_oo__} \\
\end{tabular}
\end{footnotesize}
\end{center}
\Hrule
\end{figure}

The entry point of the main program unit is called \code{MAIN__}.
The symbol name for the blank common block is \code{__BLNK__}.
the external name of the unnamed \code{BLOCK DATA} routine is
\code{__BLOCK_DATA__}.

\subsection{Representation of Fortran Types}
\label{sub_fortran_types}

For historical reasons, GNU Fortran 77 maps Fortran programs to the C
ABI, so the data representation can be explained best by providing the
mapping of Fortran types to C types used by G77 on AMD64\footnote{G77
  provides a header \code{g2c.h} with the equivalent C type
  definitions for all supported Fortran scalar types.} as in figure~
\ref{fortran-c-types}.  The ``\code{TYPE*N}'' notation specifies that
variables or aggregate members of type \code{TYPE} shall occupy
\code{N} bytes of storage.


\begin{figure}[H]
\Hrule
\caption{Mapping of Fortran to C types} \label{fortran-c-types}
\begin{center}
\begin{footnotesize}
\begin{tabular}{l|l|l}
\multicolumn{1}{c}{Fortran}&\multicolumn{1}{c}{Data
  kind}&\multicolumn{1}{c}{Equivalent C type}\\
\hline
\code{INTEGER*4}      &  Default integer                       &  \code{signed int} \\
\code{INTEGER*8}      &  Double precision integer              &  \code{signed long}\\
\code{REAL*4}         &  Single precision FP number            &  \code{float}\\
\code{REAL*8}         &  Double precision FP number            &  \code{double}\\
\code{COMPLEX*4}      &  Single precision complex FP number    &  \code{complex float}\\
\code{COMPLEX*8}      &  Double precision complex FP number    &  \code{complex double}\\
\code{LOGICAL}        &  Boolean logical type                  &  \code{signed int}\\
\code{CHARACTER}      &  Text string                           &  \code{char[] + length}\\
\end{tabular}
\end{footnotesize}
\end{center}
\Hrule
\end{figure}

The values for type \code{LOGICAL} are \code{.TRUE.} implemented as 1 and
\code{.FALSE.} implemented as 0.

Data objects with a \code{CHARACTER} type\footnote{This includes sub-strings.}
are represented as an array
of characters of the C char type (not guaranteed to be
``\code{$\backslash$0}'' terminated) with a separate length counter to
distinguish between \code{CHARACTER} data objects with a
length parameter, and aggregate types of \code{CHARACTER} data
objects, possibly also with a length parameter.

Layout of other aggregate types is implementation defined.  GNU
Fortran puts all arrays in contiguous memory in column-major order.
GNU Fortran 95 builds an equivalent C struct for derived types without
reordering the type fields.  Other compilers may use other
representations as needed.  The representation and use of Fortran
90/95 array descriptors is implementation defined.  Note that array indices
start at 1 by default.

Fortran 90/95 allow different kinds of each basic type using the \code{kind}
type parameter of a type.  Kind type parameter values are
implementation defined.

Layout of he commonly used Cray pointers is implementation defined.

\subsection{Argument Passing}

For each given Fortran 77 procedure, an equivalent C prototype can
be derived. Once this equivalent C prototype is known, the C ABI
conventions should be applied to determine how arguments are passed
to the Fortran procedure.

G77 passes all (user defined) formal arguments of a procedure by
reference.  Specifically, pointers to the location in memory of a
variable, array, array element, a temporary location that holds the
result of evaluating an expression or a temporary or permanent
location that holds the value of a constant (xf. g77 manual) are
passed as actual arguments. Artificial compiler generated arguments
may be passed by value or by reference as they are inherently
compiler and hence implementation specific.

Data objects with a \code{CHARACTER} type are passed as a pointer to
the character string and its length, so that each \code{CHARACTER}
formal argument in a Fortran procedure results in two actual arguments
in the equivalent C prototype.  The first argument occupies the
position in the formal argument list of the Fortran procedure.  This
argument is a pointer to the array of characters that make up the
string, passed by the caller.  The second argument is appended to the
end of the user-specified formal argument list.  This argument is of
the default integer type and its value is the length of the array of
characters, that is the length, passed as the first argument.  This
length is passed by value.
When more than one \code{CHARACTER} argument is present in an argument
list, the length arguments are appended in the order the original
arguments appear.  The above discussion also applies to sub-strings.

This ABI does not define the passing of optional arguments.  They are
allowed only in Fortran 90/95 and their passing is implementation defined.

This ABI does not define array functions (function returning arrays).
They are allowed only in Fortran 90/95 and requires the definition of
array descriptors.

Note that Fortran 90/95 procedure arguments with the \code{INTENT(IN)}
attribute should also passed by reference if the procedure is to be
linked with code written in Fortran 77.  Fortran 77 does not and can
not support the \code{INTENT} attribute because it has no concept of
explicit interfaces.  It is therefore not possible to declare the
callee's arguments as \code{INTENT(IN)}.  A Fortran 77 compiler must
assume that all procedure arguments are \code{INTENT(INOUT)} in the
Fortran 90/95 sense.


\subsection{Functions}

The calling of statement functions is implementation defined (as they
are defined only locally, the compiler has the freedom to apply any
calling convention it likes).

Subroutines with alternate returns (e.g. "SUBROUTINE X(*,*)" called
as "CALL X(*10,*20)") are implemented as functions returning
an \code{INTEGER} of the default kind.  The value of this returned integer
is whatever integer is specified in the "RETURN" statement for
the subroutine \footnote{
This integer indicates the position of an alternate
return from the subroutine in the formal argument list}, or 0 for
a \code{RETURN} statement without an argument.  It is up to the caller
to jump to the corresponding alternate return label.  The actual
alternate-return arguments are omitted from the calling sequence.

An example:

\begin{footnotesize}
\begin{verbatim}
       SUBROUTINE SHOW_ALTERNATE_RETURN (N)
          INTEGER N
          CALL ALTERNATE_RETURN_EXAMPLE (N, *10, *20, *30)
          WRITE (*,*) 'OK - Normal Return'
          RETURN
10        WRITE (*,*) '1st alternate return'
          RETURN
20        WRITE (*,*) '2nd alternate return'
          RETURN
30        WRITE (*,*) '2nd alternate return'
          RETURN
       END

       SUBROUTINE ALTERNATE_RETURN_EXAMPLE (N, *, *, *)
          INTEGER N
          IF (N .EQ. 0 ) RETURN     ! Implicit "RETURN 0"
          IF ( N .EQ. 1 ) RETURN 1
          IF ( N .EQ. 2 ) RETURN 2
          RETURN 3
       END
\end{verbatim}
\end{footnotesize}

Here the \code{SUBROUTINE ALTERNATE_RETURN_EXAMPLE} is implemented as
a function returning an \code{INTEGER*4} with value 0 if N is 0, 1 if N is 1,
2 if N is 2 and 3 for all other values of N.  This return value is used by
the caller as if the actual call were replaced by this sequence:
\begin{footnotesize}
\begin{verbatim}
          INTEGER X
          X = CALL ALTERNATE_RETURN_EXAMPLE (N)
          GOTO (10, 20, 30), X
\end{verbatim}
\end{footnotesize}

All in all the effect is that the index of the returned to label (starting
from 1) will be contained in \RAX after the call.

Alternate \code{ENTRY} points of a \code{SUBROUTINE} or \code{FUNCTION}
should be treated as separate subprograms, as mandated by the Fortran
standard.  I.e. arguments passed to an alternate \code{ENTRY} should be passed
as if the alternate \code{ENTRY} is a separate \code{SUBROUTINE} or
\code{FUNCTION}.  If a \code{FUNCTION} has alternate \code{ENTRY} points,
the result of each of the alternate \code{ENTRY} points must be returned
as if the alternate \code{ENTRY} is a separate \code{FUNCTION} with the
result type of the alternate \code{ENTRY}.  The external naming of alternate
\code{ENTRY} points follows section~\ref{sub_fortran_names}.

\subsection{COMMON blocks}
In absence of any \code{EQUIVALENCE} declaration involving variables
in \code{COMMON} blocks the layout of a 
\code{COMMON} block is exactly the same as the layout of the equivalent C
structure (with types of variables substituted according to section~
\ref{sub_fortran_types}), including the alignment requirements.

This ABI defines the layout under presence of \code{EQUIVALENCE} statements only
in some cases:
\begin{itemize}
\item the layout of the \code{COMMON} block must not change if one ignores
      the \code{EQUIVALENCE}, which amongst other things means:
\item If two arrays are equivalenced, the larger array must be named in
      the \code{COMMON} block, and there must be complete inclusion,
      in particular the other array may not extend the size of the 
      equivalenced segment.  It may also not change the alignment
      requirement.
\item If an array element and a scalar are equivalenced, the array must be
      named in the \code{COMMON} block and it must not be smaller than
      the scalar.  The type of the scalar must not require bigger alignment
      than the array.
\item if two scalars are equivalenced they must have the same size and
      alignment requirements.
\end{itemize}

Other cases are implementation defined.

Because the Fortran standard allows the blank \code{COMMON} block to have
different sizes in different subprograms, it may be impossible to determine
if it is small enough to fit in the \texttt{.bss}
section.  When compiling for the medium or large code models the blank
\code{COMMON} block should therefore always be put in the \texttt{.lbss}
section.

\subsection{Intrinsics}
This sections lists the set of intrinsics which has to be supported
at minimum by a conforming compiler.  They are separated by origin.
They follow regular calling and naming conventions.

The signature of intrinsics uses the syntax
$return-type(argtype1, argtype2, ...)$, where the individual types can
be the following characters: {\bf V} (as in void) designates a
\code{SUBROUTINE}, {\bf L} a \code{LOGICAL}, {\bf I} an \code{INTEGER},
{\bf R} a \code{REAL}, and {\bf C} a \code{CHARACTER}.
Hence \code{I(R,L)} designates a \code{FUNCTION} returning an
\code{INTEGER} and taking a \code{REAL} and a \code{LOGICAL}.
If an argument is an array, this is indicated using a trailing number,
e.g. {\bf I13} is an \code{INTEGER} array with 13 elements.
If a \code{CHARACTER} argument or return value has a fixed length, this
is indicated using an asterisk and a trailing number, for example
{\bf C*16} is a \code{CHARACTER(len=16)}.  If a \code{CHARACTER}
argument of arbitrary length must be passed, the trailing number is
replaced with \code{N}, for example {\bf C*N}.


\begin{table}[H]
\Hrule
  \caption{Mil intrinsics}
  \label{intrinsics-mil}
  \begin{center}
  \begin{tabular}[t]{l|l|l}
    \multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Signature} & \multicolumn{1}{c}{Meaning} \\
    \hline
    \code{BTest}  & L(I,I)          & Test bit \\
    \code{IAnd}   & I(I,I)          & Boolean AND \\
    \code{IOr}    & I(I,I)          & Boolean OR \\
    \code{IEOr}   & I(I,I)          & Boolean XOR \\
    \code{Not}    & I(I)            & Boolean NOT \\
    \code{IBClr}  & I(I,I)          & Clear a bit \\
    \code{IBits}  & I(I,I,I)        & Extract a bit subfield of a variable \\
    \code{IBSet}  & I(I,I)          & Set a bit \\
    \code{IShft}  & I(I,I)          & Logical bit shift \\
    \code{IShftC} & I(I,I,I)        & Circular bit shift \\
    \code{MvBits} & V(I,I,I,I,I)    & Move a bit field \\
  \end{tabular}
  \end{center}
\Hrule
\end{table}

\begin{itemize}
  \item[\tt BTest]{\tt (I, Pos)}
    Returns \code{.TRUE.} if bit \code{Pos} in \code{I} is set,
    returns \code{.FALSE.} otherwise.
  \item[\tt IAnd]{\tt (I, J)}
    Returns value resulting from a boolean AND on each pair of bits
    in \code{I} and \code{J}.
  \item[\tt IOr]{\tt (I, J)}
    Returns value resulting from a boolean OR on each pair of bits
    in \code{I} and \code{J}.
  \item[\tt IEOr]{\tt (I, J)}
    Returns value resulting from a boolean XOR on each pair of bits
    in \code{I} and \code{J}.
  \item[\tt Not]{\tt (I)}
    Returns value resulting from a boolean NOT on each bit in \code{I}.
  \item[\tt IBClr]{\tt (I, Pos)}
    Returns the value of \code{I} with bit \code{Pos} cleared (set to zero).
  \item[\tt IBits]{\tt (I, Pos, Len)}
    Extracts a subfield starting from bit position \code{Pos} and with a
    length (towards the most significant bit) of \code{Len} bits from \code{I}.
    The result is right-justified and the remaining bits are zeroed.
  \item[\tt IBSet]{\tt (I, Pos)}
    Returns the value of \code{I} with the bit in position \code{Pos} set to one.
  \item[\tt IShft]{\tt (I, Shift)}
    All bits of \code{I} are shifted \code{Shift} places.
    \code{Shift.GT.0} indicates a left shift,
    \code{Shift.EQ.0} indicates no shift, and
    \code{Shift.LT.0} indicates a right shift.
    Bits shifted out from the least (when shifting right) or
    most (when shifting left) significant position are lost.
    Bits shifted in at the opposite end are not set (i.e. zero).
  \item[\tt IShftC]{\tt (I, Shift, Size)}
    The rightmost \code{Size} bits of the argument \code{I} are shifted
    circularly \code{Shift} places.
    The unshifted bits of the result are the same as the unshifted bits of I.
  \item[\tt MvBits]{\tt (From, FromPos, Len, To, ToPos)}
    Move \code{Len} bits of \code{From} from bit positions \code{FromPos}
    through \code{FromPos+Len-1} to bit positions \code{ToPos} through
    \code{ToPos+Len-1} of \code{To}. The bit portions of \code{To} that
    are not affected by the movement of bits are unchanged.
\end{itemize}

\begin{table}[H]
\Hrule
  \caption{F77 intrinsics}
  \label{intrinsics-f77}
  \begin{center}
  \begin{tabular}[t]{l|l}
    \multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Meaning} \\
    \hline
    Abs & Absolute value \\
    ACos & Arc cosine \\
    AInt & Truncate to whole number \\
    ANInt & Round to nearest whole number \\
    ASin & Arc sine \\
    ATan & Arc Tangent \\
    ATan2 & Arc Tangent \\
    Char & Character from code \\
    Cmplx & Construct \code{COMPLEX(KIND=1)} value \\
    Conjg & Complex conjugate \\
    Cos & Cosine \\
    CosH & Hyperbolic cosine \\
    Dble & Convert to double precision \\
    DiM & Difference magnitude (non-negative subtract) \\
    DProd & Double-precision product \\
    Exp & Exponential \\
    IChar & Code for character \\
    Index & Locate a \code{CHARACTER} substring \\
    Int & Convert to \code{INTEGER} value truncated to whole number \\
    Len & Length of character entity \\
    LGe & Lexically greater than or equal \\
    LGt & Lexically greater than \\
    LLe & Lexically less than or equal \\
    LLt & Lexically less than \\
    Log & Natural logarithm \\
    Log10 & Common logarithm \\
    Max & Maximum value \\
    Min & Minimum value \\
    Mod & Remainder \\
    NInt & Convert to \code{INTEGER} value rounded to nearest whole number \\
    Real & Convert value to type \code{REAL(KIND=1)} \\
    Sin & Sine \\
    SinH & Hyperbolic sine \\
    SqRt & Square root \\
    Tan & Tangent \\
    TanH & Hyperbolic tangent \\
  \end{tabular}
  \end{center}
\Hrule
\end{table}

Refer to the Fortran 77 language standard for signature and definition
of the F77 intrinsics listed in table~\ref{intrinsics-f77}.  These intrinsics
can have a prefix as per the standard hence the table is not exhaustive.

\begin{table}[H]
\Hrule
  \caption{F90 intrinsics}
  \label{intrinsics-f90}
  \begin{center}
  \begin{tabular}[t]{l|l}
    \multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Meaning} \\
    \hline
    AChar & ASCII character from code \\
    Bit_Size & Number of bits in arguments type \\
    CPU_Time & Get current CPU time \\
    IAChar & ASCII code for character \\
    Len_Trim & Get last non-blank character in string \\
    System_Clock & Get current system clock value \\
  \end{tabular}
  \end{center}
\Hrule
\end{table}

Refer to the Fortran 90 language standard for signature and definition
of the F90 intrinsics listed in table~\ref{intrinsics-f90}.

\begin{table}[H]
\Hrule
  \caption{Math intrinsics}
  \label{intrinsics-math}
  \begin{center}
  \begin{tabular}[t]{l|l|l}
    \multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Signature} & \multicolumn{1}{c}{Meaning} \\
    \hline
    \code{BesJ0} & R(R)   & Bessel function \\
    \code{BesJ1} & R(R)   & Bessel function \\
    \code{BesJN} & R(I,R) & Bessel function \\
    \code{BesY0} & R(R)   & Bessel function \\
    \code{BesY1} & R(R)   & Bessel function \\
    \code{BesYN} & R(I,R) & Bessel function \\
    \code{ErF}   & R(R)   & Error function \\
    \code{ErFC}  & R(R)   & Complementary error function \\
    \code{IRand} & I(I)   & Random number \\
    \code{Rand}  & R(I)   & Random number \\
    \code{SRand} & V(I)   & Random seed \\
  \end{tabular}
  \end{center}
\Hrule
\end{table}

\begin{itemize}
  \item[\tt BesJ0]{\tt (X)}
    Calculates the Bessel function of the first kind of order 0 of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt BesJ1]{\tt (X)}
    Calculates the Bessel function of the first kind of order 1 of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt BesJN]{\tt (N, X)}
    Calculates the Bessel function of the first kind of order N of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt BesY0]{\tt (X)}
    Calculates the Bessel function of the second kind of order 0 of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt BesY1]{\tt (X)}
    Calculates the Bessel function of the second kind of order 1 of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt BesYN]{\tt (N, X)}
    Calculates the Bessel function of the second kind of order N of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt ErF]{\tt (X)}
    Calculates the error function of X.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt ErFC]{\tt (X)}
    Calculates the complementary error function of X, i.e. \code{1 - ERF(X)}.
    Returns a \code{REAL} of the same kind as \code{X}.
  \item[\tt IRand]{\tt (Flag)}
    Flag is optional.
    Returns a uniform quasi-random number up to a system-dependent limit.
    If \code{Flag .EQ. 0} or \code{Flag} is not passed, the next number
    in sequence is returned.
    If \code{Flag .EQ. 1}, the generator is restarted.
    If \code{Flag} has any other value, the generator is restarted with
    the value of \code{Flag} as the new seed.
  \item[\tt Rand]{\tt (Flag)}
    Flag is optional.
    Returns a uniform quasi-random number between 0 and 1.
    If \code{Flag .EQ. 0} or \code{Flag} is not passed, the next number
    in sequence is returned.
    If \code{Flag .EQ. 1}, the generator is restarted.
    If \code{Flag} has any other value, the generator is restarted with
    the value of \code{Flag} as the new seed.
  \item[\tt SRand]{\tt (Seed)}
    Reinitializes the random number generator for \code{IRand} and \code{Rand}
    with the seed in \code{Seed}.
\end{itemize}

\begin{table}[H]
\Hrule
  \caption{Unix intrinsics}
  \label{intrinsics-unix}
  \begin{center}
  \begin{tabular}[t]{l|l|l}
    \multicolumn{1}{c}{Name} & \multicolumn{1}{c}{Signature} & \multicolumn{1}{c}{Meaning} \\
    \hline
    \code{Abort}  & V()               & Abort the program \\
    \code{Access} & I(C,C)            & Check file accessibility \\
    \code{DTime}  & V(R2,R)           & Get elapsed time since last call \\
    \code{ETime}  & V(R2,R)           & Get elapsed time for process \\
    \code{Flush}  & V(I)              & Flush buffered output \\
    \code{FNum}   & I(I)              & Get file descriptor from Fortran unit number \\
    \code{FStat}  & V(I,I13,I)        & Get file information \\
    \code{GError} & V(C*N)            & Get error message for last error \\
    \code{GetArg} & V(I,C*N)          & Obtain command-line argument \\
    \code{GetCWD} & V(C*N,I)          & Get current working directory \\
    \code{GetEnv} & V(C*N,C*N)        & Get environment variable \\
    \code{GetGId} & I()               & Get process group ID \\
    \code{GetPId} & I()               & Get process ID \\
    \code{GetUId} & I()               & Get process user ID \\
    \code{GetLog} & V(C*N)            & Get login name \\
    \code{HostNm} & V(C*N,I)          & Get host name \\
    \code{IArgC}  & I()               & Obtain count of command-line arguments \\
    \code{IDate}  & V(I3)             & Get local date info \\
    \code{IErrNo} & I()               & Get error number for last error \\
    \code{ITime}  & V(I3)             & Get local time of day \\
    \code{LStat}  & V(C*N,I13,I)      & Get file information \\
    \code{PError} & V(C*N)            & Print error message for last error \\
    \code{Rename} & V(C*N,C*N,I)      & Rename file \\
    \code{Sleep}  & V(I)              & Sleep for a specified time \\
    \code{System} & V(C*N,I)          & Invoke shell (system) command \\
  \end{tabular}
  \end{center}
\Hrule
\end{table}


\begin{itemize}
  \item[\tt Abort]{\tt ()}
    Prints a message and potentially causes a core dump.
  \item[\tt Access]{\tt (Name, Mode)}
    Checks file \code{Name} for accessibility in the mode specified by
    \code{Mode}.  Returns $0$ if the file is accessible in that mode,
    otherwise an error code.  \code{Name} must be a \code{NULL}-terminated
    string of \code{CHARACTER} (i.e. a C-style string).  Trailing blanks
    in \code{Name} are ignored.
    \code{Mode} must be a concatenation of any of the following characters:
    {\bf r} meaning test for read permission, {\bf w} meaning test for write
    permission, {\bf x} meaning test for execute/search permission, or
    a space meaning test for existence of the file.
  \item[\tt DTime]{\tt (TArray, Result)}
    When called for the first time, returns the number of seconds of runtime
    since the start of the program in \code{Result}, the user component of
    this runtime in \code{TArray(1)}, and the system time in \code{TArray(2)}.
    Subsequent invocations values based on accumulations since the previous
    invocation.
  \item[\tt ETime]{\tt (TArray, Result)}
    Returns the number of seconds of runtime since the start of the program
    in \code{Result}, the user component of
    this runtime in \code{TArray(1)}, and the system time in \code{TArray(2)}.
    Subsequent invocations values based on accumulations since the previous
    invocation.
  \item[\tt Flush]{\tt (Unit)}
    Flushes the Fortran I/O unit with ID \code{Unit}.  The unit must be open
    for output. If the optional \code{Unit} argument is omitted, all open
    units are flushed.
  \item[\tt FNum]{\tt (Unit)}
    Returns the UNIX(tm) file descriptor number corresponding to the Fortran
    I/O unit \code{Unit}.  The unit must be open.
  \item[\tt FStat]{\tt (Unit, SArray, Status)}
    Obtains data about the file open on Fortran I/O unit \code{Unit} and
    places it in the array \code{SArray}. The values in this array are
    as follows:
    \begin{enumerate}
      \item Device ID 
      \item Inode number 
      \item File mode 
      \item Number of links 
      \item Owner's UID 
      \item Owner's GID 
      \item ID of device containing directory entry for file
      \item File size (bytes) 
      \item Last access time 
      \item Last modification time 
      \item Last file status change time 
      \item Preferred I/O block size (-1 if not available) 
      \item Number of blocks allocated (-1 if not available)
    \end{enumerate}
    If an element is not available, or not relevant on the host system,
    it is returned as 0 except when indicated otherwise in the above list.
    If the optional \code{Status} argument is supplied, it contains 0 on
    success or a nonzero error code upon return.
  \item[\tt Gerror]{\tt (Message)}
    Returns the system error message corresponding to the last system error
    (errno in C). The message is returned in \code{Message}.
    If \code{Message} is longer than the error message, it is padded with
    blanks after the message.  If \code{Message} is not long enough to hold
    the error message, the error message is truncated to the length of
    \code{Message}.
  \item[\tt GetArg]{\tt (Pos, Value)}
    Returns in \code{Value} the command-line argument in position \code{Pos}.
    If there are fever than \code{Pos} command-line arguments, \code{Value}
    is filled with blanks.  If \code{Pos} is 0, the name of the program is
    returned.
    If \code{Value} is longer than the command-line argument, it is padded
    with blanks after the argument.  If \code{Value} is not long enough to
    hold the command-line argument, the argument is truncated to the length
    of \code{Value}.
  \item[\tt GetCWD]{\tt (Name, Status)}
    Returns in \code{Name} the current working directory. If the optional
    \code{Status} argument is supplied, it contains 0 on success or a
    nonzero error code upon return.
  \item[\tt GetEnv]{\tt (Name, Value)}
    Returns in \code{Value} the environment variable identified with
    \code{Name}.  If \code{Name} has not been set, \code{Value} is filled
    with blanks. A \code{null} character marks the end of the name in
    \code{Name}. Trailing blanks in \code{Name} are ignored.
    If \code{Value} is longer than the environment variable, it is padded
    with blanks after the variable.  If \code{Value} is not long enough to
    hold the environment variable, the variable is truncated to the length
    of \code{Value}.
  \item[\tt GetGId]{\tt ()}
    Returns the group ID for the current process.
  \item[\tt GetPId]{\tt ()}
    Returns the process ID for the current process.
  \item[\tt GetUId]{\tt ()}
    Returns the user ID for the current process.
  \item[\tt GetLog]{\tt (Login)}
    Returns the login name for the process in \code{Login}, or a blank
    string if the host system does not support \code{getlogin(3)}.
    If \code{Login} is longer than the login name, it is padded
    with blanks after the login name.  If \code{Login} is not long enough
    to hold the login name, the login name is truncated to the length of
    of \code{Login}.
  \item[\tt HotNm]{\tt (Name, Status)}
    Returns in \code{Name} system's host name. If the optional \code{Status}
    argument is supplied, it contains 0 on success or a nonzero error code
    upon return.
    If \code{Name} is longer than the host name, it is padded
    with blanks after the host name.  If \code{Name} is not long enough
    to hold the host name, the host name is truncated to the length of
    of \code{Name}.
  \item[\tt IArgC]{\tt ()}
    Returns the number of command-line arguments.  The program name
    itself is not included in this number.
  \item[\tt IDate]{\tt (TArray)}
    Returns the current local date day, month, year in
    elements 1, 2, and 3 of \code{Tarray}, respectively.
    The year has four significant digits. 
  \item[\tt IErrno]{\tt ()}
    Returns the last system error number (\code{errno} in C).
  \item[\tt ITime]{\tt (TArray)}
    Returns the current local time hour, minutes, and seconds in
    elements 1, 2, and 3 of \code{TArray}, respectively.
  \item[\tt LStat]{\tt (File, SArray, Status)}
    Obtains data about a file named \code{File} and places places it in
    the array \code{SArray}. The values in this array are as follows:
    \begin{enumerate}
      \item Device ID 
      \item Inode number 
      \item File mode 
      \item Number of links 
      \item Owner's UID 
      \item Owner's GID 
      \item ID of device containing directory entry for file
      \item File size (bytes) 
      \item Last access time 
      \item Last modification time 
      \item Last file status change time 
      \item Preferred I/O block size (-1 if not available) 
      \item Number of blocks allocated (-1 if not available)
    \end{enumerate}
    If an element is not available, or not relevant on the host system,
    it is returned as 0 except when indicated otherwise in the above list.
    If the optional \code{Status} argument is supplied, it contains 0 on
    success or a nonzero error code upon return.
  \item[\tt PError]{\tt (MsgPrefix)}
    Prints a newline-terminated error message corresponding to the last
    system error. This is prefixed by the string \code{MsgPrefix},
    a colon and a space.  The error message is printed on the C
    {\tt stderr} stream.
  \item[\tt Rename]{\tt (Path1, Path2, Status)}
    Renames the file named \code{Path1} to \code{Path2}. A \code{null}
    character marks the end of the names.  Trailing blanks are ignored.
    If the optional \code{Status} argument is supplied, it contains 0
    on success or a nonzero error code upon return.
  \item[\tt Sleep]{\tt (Seconds)}
    Causes the program to pause for \code{Seconds} seconds.
  \item[\tt System]{\tt (Command, Status)}
    Passes the string in \code{Command} to a shell though {\tt system(3)}.
    If the optional argument \code{Status} is present, it contains the
    value returned by {\tt system(3)}.
\end{itemize}

 
